export default {
  data() {
    return {
      visibleDialog: false,
      searchVal: "",
      activeName: "1",
      departments: {},
      roles: [{
        r_RoleID: 1231,
        r_RoleName: '测试'
      },{
        r_RoleID: 1,
        r_RoleName: '青山'
      },],
    }
  },
  methods: {
    getRoleList() {
      // eslint-disable-next-line no-
      
      this.$axios.get(`${process.env.BASE_URL}approvalProcess/roles.json}`).then(res => {
        // this.$axios.get(`${process.env.BASE_URL}departments-ya.json?page=1&limit=1000000&OrganID=${OrganID}`).then(res => {
        this.departments = res.data;
      });
      /* this.$axios.get(`${process.env.BASE_URL}roles.json`).then(res => {
        this.roles = res.data.list;
      }) */
    },
    // getDepartmentList(OrganID = 0) {
    getDepartmentList(parentId = 0) {
      // eslint-disable-next-line no-
      
      this.$axios.get(`${process.env.BASE_URL}approvalProcess/departments.json?parentId=${parentId}`).then(res => {
        // this.$axios.get(`${process.env.BASE_URL}departments-ya.json?page=1&limit=1000000&OrganID=${OrganID}`).then(res => {
        this.departments = res.data;
      });
      /* this.$axios.post(`http://localhost:51908/PersonManage/GetList?page=1&limit=1000000&OrganID=${OrganID}`, {}).then(res => {
        this.departments = res.data;
      }).catch((error) => {
        this.layerMsg(`保存失败，${error.Message}`);
      }); */
    },
    getDebounceData(event, type = 1) {
      this.$func.debounce(function () {
        if (event.target.value) {
          if (type == 1) {
            // this.departments.childDepartments = [];
            /* this.$axios.get(`${process.env.BASE_URL}employees.json?searchName=${event.target.value}&pageNum=1&pageSize=30`).then(res => {
              this.departments.employees = res.data.list
            }) */
            this.personList = [];
            this.$axios.post(`/PersonManage/GetList?page=1&limit=1000000&P_PersonName=${event.target.value}`, {}).then(res => {
              this.personList = res.data;
            }).catch((error) => {
              this.$message.error('请求人员接口出错，请联系管理员。', error);
            });
          } else {
            this.roles = [];
            this.$axios.post(`/RoleManage/GetList?page=1&limit=1000000&r_RoleName=${event.target.value}}`, {}).then(res => {
              this.roles = res.data;
            }).catch((error) => {
              this.$message.error('请求角色接口出错，请联系管理员。', error);
            });
            /* this.$axios.get(`${process.env.BASE_URL}roles.json?searchName=${event.target.value}&pageNum=1&pageSize=30`).then(res => {
              this.roles = res.data.list
            }) */
          }
        } else {
          type == 1 ? this.getDepartmentList() : this.getRoleList();
        }
      }.bind(this))()
    },
  }
}